package Servlet;

import Hadoop.HadoopUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


@WebServlet("/demo2")
public class ServletDemo2 extends HttpServlet {


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // hdfs 文件读取
         String srcPath =  req.getParameter("srcPath");

        HadoopUtil hadoopUtil = new HadoopUtil();//
        List result  =  hadoopUtil.hadoopRead(srcPath);


        req.setAttribute("obj_data",result);

        req.getRequestDispatcher("/queryResult.jsp").forward(req,resp);

//        resp.setContentType("text/html;charset=utf-8");
//        PrintWriter pw =  resp.getWriter();
//        pw.write(result);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }


}
